<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<base th:href="@{/}"><!-- 不用base就使用th:src="@{/js/jquery.min.js} -->
<meta charset="UTF-8">
<title>订单页面</title>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<script src="js/jquery.min.js"></script>
<script type="text/javascript" th:inline="javascript">
	function pay(){
			$.ajax(
				{
					//请求路径，要注意的是url和th:inline="javascript"
					url : [[@{/cart/pay}]],
					//请求类型
					type : "post",
					contentType : "application/json",
					//data表示发送的数据
					data : JSON.stringify({
						id : $("#oid").text()
					}),
					//成功响应的结果
					success : function(obj){//obj响应数据
						alert("支付成功");
						//获取路径
						var pathName=window.document.location.pathname;
						//截取，得到项目名称
						var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
						window.location.href = projectName;
					},
			        error : function() {
			            alert("处理异常！");
			        }
				}	
			);
	}
</script>
</head>
<body>
<div th:include="user/header"></div>
<div class="container">
	<div class="panel panel-primary">
		<div class="panel-heading">
			<h3 class="panel-title">订单列表</h3>
		</div>
		<div class="panel-body">
			<div class="table table-responsive">
				<table class="table table-bordered table-hover">
					<tbody class="text-center">
						<tr>
							<th>订单编号</th>
							<th>订单金额</th>
							<th>订单状态</th>
							<th>下单时间</th>
							<th>查看详情</th>
						</tr>
						<tr th:each="order:${myOrder}">
							<td th:text="${order.id}"></td>
							<td th:text="${order.amount}"></td>
							<td>
								<span th:if="${order.status} == 0" >
									未支付 &nbsp; <a href="javascript:pay()" >去支付</a>
								</span>
								<span th:if="${order.status} == 1" >
									已支付
								</span>
							</td>
							<td th:text="${order.orderdate}"></td>
							<td>
								<a th:href="'cart/orderDetail?id=' + ${order.id}" target="_blank">查看详情</a>
							</td>
						</tr>
					</tbody>
				</table>
			</div>
		</div>
	</div>
</div>
</body>
</html>